export default {
  name: 'register',
  mounted: function(){

  },
  methods:{
    //保存注册信息
    saveRegister(){
      let url = '/api/register/regist';
      this.$refs['addForm'].validate((valid) => {
        if (valid) {
          let params = {
            id : this.addForm.id,
            userName : this.addForm.user_name,
            password : this.$getMD5(this.addForm.password),
            companyName : this.addForm.company_name
          };
            this.axios.hPost(url, params, (response) => {
            if(response.success){
              this.$message.success(response.msg);
            }else{
              this.$message.error(response.msg);
            }
          });
        } else {
          return false;
        }
      });
    },
    jumpBack()
    {
        window.history.go(-1);
    }
  },
  data (){
    return {
      //存放分页数据
      pageInfo:{
        currentPage: 1,
        pageSize: 10,
        totalNum: 0
      },
      //分组数据
      groupList:[],
      //单位数据
      companyIdList:[],
      //是否在加载标记
      loading: true,
      addForm: {
        id : null,
        user_name: '',
        password: '',
        company_name: ''
      },
      formTitle:this.$t('register.newUsers'),
      addRules:{
        user_name: [
          { required: true, message: this.$t('message.required'), trigger: 'blur' },
          { max: 50, message: this.$t('message.length50'), trigger: 'blur' },
          { pattern: /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/, message: this.$t('message.mailFormat'), trigger: 'blur'}
        ],
        password:[
          { required: true, message: this.$t('message.required'), trigger: 'blur' },
          { min: 6, message: this.$t('message.length6-16'), trigger: 'blur' },
          { max: 16, message: this.$t('message.length6-16'), trigger: 'blur'}
        ],
        company_name:[
            {max: 20,message:this.$t('message.length50'), trigger: 'blur'},
        ]
      },

      configVisible: false,
      configLoading: false,
      menuList:[],
      defaultProps: {
        children: 'chlidList',
        label: 'menuName'
      },
      currentId: null,
      userMenus:[],
    }
  }
}
